<template>
    <view class="feedback">
        <uni-header :title="'我的反馈'"></uni-header>
        <view class="feedback-body">
            <uni-easyinput type="textarea" autoHeight v-model="content" placeholder="请输入内容"></uni-easyinput>
            <view class="btn"><button @click="onSubmitClick" type="primary">立即提交</button></view>
        </view>
        <view class="feedback-list" v-for="item in feedback">
            <view class="head">{{item.content}}</view>
            <view class="foot">{{item.create_time}}</view>
        </view>

    </view>
</template>

<script>
    import { saveFeedBack, getFeedBack } from "@/api/mine"
    export default {
        data() {
            return {
                content:"",
                feedback:[]
            }
        },
        created(){
            this.getFeedBackData()
        },
        methods: {
            onSubmitClick(){
                saveFeedBack({content:this.content,deviceId:this.$store.state.user.deviceId}).then(res=>{
                    if(res.status == 0){
                        uni.navigateBack({
                            delta: 1
                        })
                    }
                })
            },
            getFeedBackData(){
                getFeedBack({deviceId:this.$store.state.user.deviceId}).then(res=>{
                    this.feedback = res.list
                    console.log(res)
                })
            }
        }
    }
</script>

<style lang="scss">
    .feedback-body{
        padding: 15px;
        .btn{
            margin-top: 15px;
        }
    }
    .feedback-list{
        background: #fff;
        margin: 10px 15px;
        border-radius: 10px;
        .head{
            padding: 10px;
            border-bottom: 1px solid #eee;
        }
        .foot{
            padding: 10px;
        }
    }
</style>
